<?php
/**
* Display the transactions in a table fashion
*
* @author       Fabrice Douteaud <admin@clearbudget.net>
* @package      snippets
* @access       public
*/

/***********************************************************************

  Copyright (C) 2008  Fabrice Douteaud (admin@clearbudget.net)

    This file is part of ClearBudget.

    ClearBudget is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    ClearBudget is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with ClearBudget.  If not, see <http://www.gnu.org/licenses/>.


************************************************************************/
//prevent direct access
if(!defined('ENGINEON')) die('Direct access forbidden');
?>
<table class="tableReport">
<caption><?php echo $title; ?></caption>
<?php
$alt = '';
  foreach($results as $result) {
  if($alt == "") $alt = 'class="alt"';
  else $alt = '';
  // presentation row
  echo '<tr><th colspan="4"></th></tr>';
  echo '<tr id="tr-'.$result['id'].'">';
  echo '<td '.$alt.' style="width:170px">'.utf8_encode(strftime('%A %d %B %y', strtotime($result['operationDate']))).'</td>';
  echo '<td '.$alt.' style="width:70px">'.class_propertyKey::getCurrencySymbol().$report->formatNumber($result['amount']).'</td>';
  echo '<td '.$alt.' style="width:250px">';
  echo '<select id="categorySelector'.$result['id'].'" class="categorySelector">';
  // list all possible categories
  foreach($categories as $id=>$name) {
    // show the uncategorized option only is item is already uncategorized
    if($id == 1 && $result['category'] != 1) continue;
    echo '<option value="'.$id.'"';
    if($result['category'] == $id) echo ' selected="selected"';
    echo '>'.$name.'</option>';
    }
  echo '</select> <a href="#" categorySelectorSave="true" id="'.$result['id'].'">'.$keys->link_save.'</a><span><img class="hidden" id="catLoading-'.$result['id'].'" src="style/icons/icon_Loading.gif"></span>';
  echo '</td>';
  echo '<td '.$alt.'> '.$result['payee'].' ('.$result['memo'].')<br/>';
  echo $keys->text_memo.': <input class="commentEntry" type="text" size="50" id="commentEntry'.$result['id'].'" value="'.$result['comments'].'">';
  echo ' <a href="#" commentEntrySave="true" id="'.$result['id'].'">'.$keys->link_save.'</a>';
  echo '<span><img class="hidden" id="commentLoading-'.$result['id'].'" src="style/icons/icon_Loading.gif"></span></td>';
  echo '</tr>';
  }
?>
</table>
<?php return; ?>








<table class="tableReport">
<caption><?php echo $title; ?></caption>
<tr>
  <th><?php echo $keys->text_operationDate; ?></th>
  <th><?php echo $keys->text_amount; ?></th>
  <th colspan="2"><?php echo $keys->text_payee; ?></th>
  
</tr>
<?php
$i = 0;
  foreach($results as $result) {
  $i++;
  // presentation row
  echo '<tr id="tr-'.$result['id'].'">';
  echo '<td rowspan="2">'.strftime('%d %B %y<br/>[ %A ]', strtotime($result['operationDate'])).'</td>';
  echo '<td rowspan="2">'.$report->formatNumber($result['amount']).'</td>';
  echo '<td colspan="2">'.$result['payee'].'<br/>'.$result['memo'].'</td>';
  echo '</tr>';
  
  echo '<tr><td>';//.$report->getCategoryName($result['category']);
  echo $keys->text_categoryName.': <select id="categorySelector-'.$result['id'].'" class="categorySelector"><option value="0">'.$keys->link_pickInTheList.'</option>';
  foreach($categories as $id=>$name) {
    echo '<option value="'.$id.'"';
    if($result['category'] == $id) echo ' selected="selected"';
    echo '>'.$name.'</option>';
    }
  echo '</select>';
  echo '</td>';
  echo '<td>';
  echo $keys->text_memo.': <input class="commentEntry" type="text" size="15" id="commentEntry-'.$result['id'].'" value="'.$result['comments'].'">';
  echo '</td></tr>';  
  }
?>
</table>
